package im.eg.service;

import im.eg.spring.anno.Component;
import im.eg.spring.itfs.BeanNameAware;

@Component("userMapper")
public class UserMapper implements BeanNameAware {

    //怎么拿到beanName呢？
    //答：通过实现BeanNameAware接口，框架在创建bean时会判断bean是否实现BeanNameAware接口，如果实现了则调用回调方法
    private String beanName;

    @Override
    public void setBeanName(String name) {
        beanName = name;
    }

    public void test() {
        System.out.println(beanName);
    }
}
